/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-08-27 15:32:24
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\CostMonth.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton, ExecuteButton } from '../Common/options'
import dayjs from 'dayjs'

export const AccountsReceivableMonth = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    console.log(Permission)
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}Two`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '77031bd5-d101-42ee-9307-4a2146b22a14') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'CostMonth' },
            commonTableList.uuid,
            {
                dataIndex: 'eventDate',
                title: '申报年月',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
                render: (_, e) => <div>{dayjs(e.eventDate).format('YYYY-MM-DD')}</div>,
            },
            {
                dataIndex: 'createTime',
                title: '填报日期',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
                hideInSearch: true,
            },
            commonTableList.StartTime,
            commonTableList.EndTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        Permission.findIndex(v => v.uuid === 'cec98a6b-e7af-41c8-ae0d-31c0324d20ad') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '65e0a850-96db-421f-8fba-9731f722af8f') !== -1 && (
                            <OpenExcelButton
                                key="one"
                                title="应收账款"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    submit: true,
                                    AccountsReceivableMonthUuid: uuid,
                                    url: 'getAccountsReceivableMonthUuidDetail',
                                    pos: 'posAccountsReceivableMonthSaveAccountsReceivable',
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '56b67ce1-5ba9-4d7c-b329-c2a1b210eb60') !== -1 && (
                            <OpenExcelButton
                                key="two"
                                title="收入成本明细"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    submit: true,
                                    AccountsReceivableMonthUuid: uuid,
                                    url: 'getAccountsReceivableMonthGetCostMonthDetail',
                                    pos: 'posAccountsReceivableMonthSaveCostDetail',
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '23212682-9f97-41ff-822d-869ac3e8c778') !== -1 && (
                            <OpenExcelButton
                                key="thr"
                                title="收入成本汇总"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    submit: true,
                                    AccountsReceivableMonthUuid: uuid,
                                    url: 'getAccountsReceivableMonthGetCostSummary',
                                    pos: 'posAccountsReceivableMonthSaveCostSummary',
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '45244222-9de0-47c6-93b5-99ffce467a0c') !== -1 && (
                            <OpenExcelButton
                                key="fou"
                                title="汇总表"
                                OptionsEvent={OptionsEvent}
                                data={{
                                    save: true,
                                    submit: true,
                                    AccountsReceivableMonthUuid: uuid,
                                    url: 'getAccountsReceivableMonthGetCostReport',
                                    pos: 'posAccountsReceivableMonthSaveCostReport',
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '07a89703-830d-4ce0-850e-7a86ef354a1d') !== -1 && (
                            <ExecuteButton
                                actionRef={actionRef}
                                key="fiv"
                                title="清除明细"
                                url="posAccountsReceivableMonthDel"
                                path={[uuid]}
                                tips="明细数据已清除!"
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '974605d1-b78f-4779-aa11-57ed910e1a06') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    return data
}
